﻿Module Module1

    Sub Main()
        Dim pvp, canti, iva, descu, percent As String
        Dim result As Decimal
        Console.Title = "Ejercicio if condicional 8"
        percent = ""

        Do
            Console.Write("PVP : ")
            pvp = Console.ReadLine()
        Loop While Not IsNumeric(pvp)

        Do
            Console.Write("Cantidad : ")
            canti = Console.ReadLine()
        Loop While Not IsNumeric(canti)

        Console.Write("IVA (General/Reducido/Superreducido) : ")
        iva = Console.ReadLine()
        While Not (iva.ToLower.Contains("general") Or iva.ToLower.Contains("reducido") Or iva.ToLower.Contains("supereducido"))
            Console.Write("Error en el IVA, Introduzca (General/Reducido/Superreducido) : ")
            iva = Console.ReadLine()
        End While

        Do
            Console.Write("¿Estudias o trabajas en el intituto(S/N)? ")
            descu = Console.ReadLine()
        Loop While Not (descu.ToUpper = "S" Or descu.ToUpper = "N")

        If descu.ToUpper = "S" Then
            Do While Not IsNumeric(percent)
                Console.Write("Descuento (%) ")
                percent = Console.ReadLine()
            Loop
        End If

        result = (CType(pvp, Decimal) * CType(canti, Integer))
        'Dim tiva As Decimal

        Select Case iva.ToLower
            Case "general"
                '       tiva = 0.21
                result = result + result * 0.21
            Case "reducido"
                result = result + result * 0.1

            Case "superreducido"
                result = result + result * 0.04


        End Select

        'result = result + result * tiva
        If IsNothing(percent) Or Not IsNumeric(percent) Then
            Console.WriteLine("Total a Pagar : " & result)
        Else
            Console.WriteLine("Total a Pagar : " & (result - result * (CType(percent, Integer) / 100)))
        End If

        'If IsNumeric(percent) Then
        '    result = result - result * (CType(percent, Integer) / 100)
        'End If
        'Console.WriteLine("Total a Pagar : " & result)

        Console.ReadKey()

    End Sub

End Module
